﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataRoute" @search="()=>{getTableDataRoute();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RouteCode_FormItem" prop="RouteCode" :label="$t('message.autotrans._Model_Route_RouteCode')">
            <el-input v-model="searchDataRoute.RouteCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RouteName_FormItem" prop="RouteName" :label="$t('message.autotrans._Model_Route_RouteName')">
            <el-input v-model="searchDataRoute.RouteName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RouteVersion_FormItem" prop="RouteVersion" :label="$t('message.autotrans._Model_Route_RouteVersion')">
            <el-input v-model="searchDataRoute.RouteVersion" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductCode_FormItem" prop="ProductCode" :label="$t('message.autotrans._Model_Route_ProductCode')">
            <el-input v-model="searchDataRoute.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field2_FormItem" prop="Field2" :label="$t('message.autotrans._Model_Route_Field2')">
            <el-input v-model="searchDataRoute.Field2" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field3_FormItem" prop="Field3" :label="$t('message.autotrans._Model_Route_Field3')">
            <el-input v-model="searchDataRoute.Field3" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field4_FormItem" prop="Field4" :label="$t('message.autotrans._Model_Route_Field4')">
            <el-input v-model="searchDataRoute.Field4" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Field5_FormItem" prop="Field5" :label="$t('message.autotrans._Model_Route_Field5')">
            <el-input v-model="searchDataRoute.Field5" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/BaseInformation/Route/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Route/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/BaseInformation/Route/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Route/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Route/RouteExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefRoute" v-bind="tableDataRoute">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/BaseInformation/Route/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/BaseInformation/Route/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/BaseInformation/Route/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationRouteIndex;true;TyMES.BaseInformation.Controllers;Route">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { routeApi } from '/@/api/baseinformation/route';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateRoute = reactive({
    
});

const searchDataRoute = ref({
        RouteCode: '',
        RouteName: '',
        RouteVersion: '',
        ProductCode: '',
        Field2: '',
        Field3: '',
        Field4: '',
        Field5: '',
});

// 定义变量内容
const tableRefRoute = ref();
const tableDataRoute = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工艺路径编码'),key: 'Route_RouteCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工艺路径名称'),key: 'Route_RouteName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工艺路径版本'),key: 'Route_RouteVersion',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品编号'),key: 'Route_ProductCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域2'),key: 'Route_Field2',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域3'),key: 'Route_Field3',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域4'),key: 'Route_Field4',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page预留域5'),key: 'Route_Field5',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataRoute = () => {
    tableRefRoute.value.doSearch(routeApi().search, searchDataRoute.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataRoute)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataRoute)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataRoute)
};

// 删除
const onDelete = (row: any) => {
    routeApi().delete([row.ID]).then(() => { getTableDataRoute()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefRoute.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      routeApi().delete(selectedids).then(() => { getTableDataRoute()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefRoute.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataRoute)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataRoute)
};

const onExport = () => {
	const selected = tableRefRoute.value.getSelectedRows();
	if (selected.length > 0) {
		routeApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		routeApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataRoute();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

